🧱 [infra] Added ty and upgraded dependencies#19
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces ty static type checking to the project’s development workflow and updates a few code locations to satisfy (or suppress) new ty-reported typing issues, alongside a small CLI default fix and dependency updates.
Changes:
- Add
tyto dev dependencies, docs, and pre-commit hooks (uv run ty check). - Update a Typer CLI argument default to use the
Commandenum value directly. - Add/adjust inline type-suppression comments and assertions to address new type-checking feedback.
Reviewed changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/dbrownell_CommitEmojis/MainApp.py | Adds assertions for row selection typing and updates ty ignore on DataTable row key usage. |
| src/dbrownell_CommitEmojis/Lib.py | Adds ty ignores for Rich API typing mismatches. |
| src/dbrownell_CommitEmojis/main.py | Uses Command.UX as the default instead of a raw string. |
| README.md | Adds a ty status badge. |
| pyproject.toml | Upgrades uv_build constraint and adds ty to the dev dependency group. |
| DEVELOPMENT.md | Documents running uv run ty check. |
| .pre-commit-config.yaml | Adds a pre-commit hook to run uv run ty check. |
| .copier-answers.yml | Enables install_ty. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| table.add_column( | ||
| col_name, | ||
| footer or "", | ||
| justify=justify, | ||
| justify=justify, # ty: ignore[invalid-argument-type] | ||
| ) |
There was a problem hiding this comment.
The # ty: ignore[invalid-argument-type] on Table.add_column(..., justify=...) bypasses type checking for this call. A more robust fix is to type justify as Rich’s expected literal type (or cast it to that type) so ty can still validate the rest of the call.
| with done_manager_or_console.YieldStdout() as stdout_stream: | ||
| console = Console(file=stdout_stream.stream) | ||
| console = Console(file=stdout_stream.stream) # ty: ignore[invalid-argument-type] | ||
| yield console |
There was a problem hiding this comment.
The # ty: ignore[invalid-argument-type] on Console(file=stdout_stream.stream) hides a type mismatch that could indicate the stream isn’t the text IO Rich expects. Prefer adapting or casting stdout_stream.stream to the appropriate TextIO/IO[str] type (or updating the DoneManager type hints) so ty can validate this call without an ignore.
| dt.add_row( | ||
| item.code, | ||
| item.name, | ||
| item.description, | ||
| ", ".join(item.aliases), | ||
| key=(item.emoji, item.aliases[0] if item.aliases else ""), # type: ignore[arg-type] | ||
| key=(item.emoji, item.aliases[0] if item.aliases else ""), # ty: ignore[invalid-argument-type] | ||
| ) |
There was a problem hiding this comment.
Using # ty: ignore[invalid-argument-type] on the DataTable.add_row(..., key=...) call reduces the value of adding ty here. If Textual expects a specific key type, consider switching the key to that type (e.g., str/RowKey) and keeping a separate mapping to (emoji, alias) instead of storing a tuple in the key.
📝 Description
Added ty and upgraded dependencies.
⚙️ Work Item
N/A
🎥 Demo
N/A